package com.sandbox.ws;

import java.util.Date;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.UnexpectedInputException;

import com.edb.finance.collateral.wsdomain.collateralitem.v1.Collateralitem;
import com.evry.finance.collateral.wsdomain.Database;

public class XmlReader implements ItemReader<Database> {

//	private BlockingQueue<Collateralitem> queue;
	
	public Database read() throws Exception, UnexpectedInputException {
		
		//1 unmarshall xml file database. 
		
		//2 loop through all items
		//logic for creating a CheckInRequest for each collateral item and add to qeue.
		
		//3. 
//		System.out.println("Enter XmlReader.read()");
//		if(queue.isEmpty()){
////			System.out.println("queue.size(): " + queue.size());
////			for (int i = 0; i < 5000; i++) {
////				queue.add(newItem(Long.valueOf(i)));
////			}
//			return newItem(1337l);
//		}else{
//			return null;
//		}
//		return database;
		
		return null;
	}

	private Collateralitem newItem(long uniquekey) {
		Collateralitem item = new Collateralitem();
		item.setAdmCollItemDesignation("234");
		item.setCollateralItemStatus("234");
		item.setCollateralItemType("234");
		item.setObjectDescription("234234");
		item.setStatusDate(new Date());
		item.setUniqueKey(uniquekey);
		return item;
	}
	
//	public void setQueue(BlockingQueue<Collateralitem> queue) {
//		this.queue = queue;
//	}
}